import { http } from '@/utils/https'
import type { BannerItem, CategoryItem, GuessItem, HotItem } from '@/types/home'
import type { PageParams, PageResult } from '@/types/global'

/**
 * 首页-广告区域-小程序
 * 广告区域展示位置
 * 1 为首页（默认值）
 * 2 为商品分类页
 */

export const getHomeBannerApi = (distributionSite = 1) => {
  return http<BannerItem[]>({
    method: 'GET',
    url: '/home/banner',
    data: {
      distributionSite,
    },
  })
}

// 首页-前台分类-小程序
// GET
// /home/category/mutli
// 小程序查询前台分类，只查询一级类目信息（此处pc和app、mini共用了一套前台类目信息）

export const getHomeCategoryApi = () => {
  return http<CategoryItem[]>({
    method: 'GET',
    url: '/home/category/mutli',
  })
}

// 首页-热门推荐-小程序
// GET
// /home/hot/mutli
export const getHomeHotApi = () => {
  return http<HotItem[]>({
    method: 'GET',
    url: '/home/hot/mutli',
  })
}

// 猜你喜欢-小程序
// GET
// /home/goods/guessLike
export const getHomeGoodsGuessLikeApi = (data?: PageParams) => {
  return http<PageResult<GuessItem>>({
    method: 'GET',
    url: '/home/goods/guessLike',
    data,
  })
}
